<layout name="bootlayout" />

<style> 
.set_div{width:100%;border-top:2px solid #ddd;padding:10px;}
</style>

<div style="margin:10px;">
	<div style="width:100%;">模型管理：</div>
			<div style="margin:10px 0 0 50px;">

<table class="table">
        <thead>
          <tr>
          	<th>model_id</th>
            <th>名称</th>
            <th>表名</th>
            <th>描述</th>
            <th>数据页面</th>
            <th>操作</th>
            
          </tr>
        </thead>
        <tbody>
        	<form action="/admin/WebSet/index" method="post" id="web_up">
         <foreach name="data" item="vo" >  
		   <tr>
            <td>{$vo.id}</td>
            <td>{$vo.name}</td>
            <td>{$vo.table}</td>
            <td>{$vo.show}</td>
            <td>{$vo.description}</td>
            <td><button type="button" class="btn btn-default" data-toggle="modal" data-target="#myModal" onclick="model_up('{$vo.id}','{$vo.name}','{$vo.table}','{$vo.description}','{$vo.show}');">修改</button></td>
          </tr>
		   </foreach>
         
		  </form>
        </tbody>
</table>
<div class="btn-group set_div">
  <button type="button" class="btn btn-default" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal" onclick="model_add()">新增</button>
</div>
<!--新增模型sart-->

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" id="myModalLabel">新增模型</h4>
      </div>
      <div class="modal-body" >
      	<form action="/admin/models/model" method="post" id="model_set">
      		<input type="hidden" id="id" name="id"/>
			    <div class="form-group">
				    <label for="exampleInputEmail1">名称</label>
				    <input type="text" class="form-control" id="name" name="name">
				  </div>
				  <div class="form-group">
				    <label for="exampleInputEmail1">表名（不含think_）</label>
				    <input type="text" class="form-control" id="table" name="table">
				  </div>
				  <div class="form-group">
				    <label for="exampleInputEmail1">数据页面</label>
				   <select name="show" id="show">
				   		<?php 					$list=glob((THEME_PATH.'Models/add_*.php'));
														foreach ($list as $r){
														$r=substr($r,32,count($r)-5);?>
										<option value="<?php echo $r;?>"><?php echo $r;?></option>
										    <?php }?> 
				   
				   </select>
				  </div>
				  <div class="form-group">
				    <label for="exampleInputEmail1">描述</label>
				    <input type="text" class="form-control" id="description" name="description">
				  </div>
				  </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary" onclick="model_save();">保存</button>
      </div>
    </div>
  </div>
</div>
<!--新增模型end-->

			</div>
</div>

<script>
function model_add(){
	$("#name").val("");
	$("#id").val("");
	$("#table").val("");
	$("#description").val("");
}

function model_up(id,name,table,description,show){
	$("#name").val(name);
	$("#id").val(id);
	$("#table").val(table);
	$("#show option[value="+show+"]").attr("selected","selected");
	$("#description").val(description);
}

function model_save(){
	$("#model_set").submit();
}
</script>


